﻿#region Header

/*
Measure emotions of a group of person
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using System.Runtime.InteropServices;

#endregion

namespace Tests.Basics {
	internal static class MapleEngine {
		// interface callback definitions

		#region Delegates

		public delegate IntPtr CallBackCallBack(IntPtr data, IntPtr output);

		public delegate void ErrorCallBack(IntPtr data, IntPtr offset, IntPtr msg);

		public delegate long QueryInterrupt(IntPtr data);

		public delegate IntPtr ReadLineCallBack(IntPtr data, IntPtr debug);

		public delegate long RedirectCallBack(IntPtr data, IntPtr name, IntPtr mode);

		public delegate void StatusCallBack(IntPtr data, IntPtr used, IntPtr alloc, double time);

		public delegate IntPtr StreamCallBack(IntPtr data, IntPtr stream, int nargs, IntPtr args);

		public delegate void TextCallBack(IntPtr data, int tag, IntPtr output);

		#endregion

		// OpenMaple API methods (there are many more commands in the API,
		// these are just the ones we are using in this example)
		[DllImport(@"maplec.dll")]
		public static extern IntPtr StartMaple(int argc, String[] argv, ref MapleCallbacks cb, IntPtr data, IntPtr info,
												byte[] err);

		[DllImport(@"maplec.dll")]
		public static extern IntPtr EvalMapleStatement(IntPtr kv, byte[] statement);

		[DllImport(@"maplec.dll")]
		public static extern IntPtr IsMapleStop(IntPtr kv, IntPtr obj);

		[DllImport(@"maplec.dll")]
		public static extern void StopMaple(IntPtr kv);

		#region Nested type: MapleCallbacks

		public struct MapleCallbacks {
			public CallBackCallBack callbackCallBack;
			public ErrorCallBack errorCallBack;
			public QueryInterrupt queryInterrupt;
			public ReadLineCallBack readlineCallBack;
			public RedirectCallBack redirectCallBack;
			public StatusCallBack statusCallBack;
			public StreamCallBack streamCallBack;
			public TextCallBack textCallBack;
		}

		#endregion
	}
}